package dome_013;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * <p>Description: []</p>
 * Created on 2020/12/15
 *
 * @author <a href="mailto: 819712047@qq.com">谢振东 </a>
 * @version 1.0
 */
public class T04_ConcurrentQueue {
    public static void main(String[] args) {
        Queue<String> strings = new ConcurrentLinkedQueue<String>();

        for (int i = 0; i < 10; i++) {
            strings.offer("a" + i); //相当于add， 放进队列
        }

        System.out.println("strings集合：" + strings);

        System.out.println("strings长度：" + strings.size());

        System.out.println("strings取出并移除：" + strings.poll()); //取出并移除掉
        System.out.println("strings长度：" + strings.size());

        System.out.println("strings取出不移除：" + strings.peek()); //取出，不会移除。相当于get(0)
        System.out.println("strings长度：" + strings.size());
    }
}
